//#include <direct.h>
#include "ansrec.h"

FIELD BufStep[Field_Num]=
{
	//记录长度--记录注释，按顺序
	{4,   "pyhsn"},
	{1,   "rectype"},
	{6,   "PsamTID"},
	{3,   "MotoEmpID"},
	{1,   "cardphtype"},
	{4,   "CounterSn"},
	{8,   "AppCardSn"},
	{1,   "HolderCardSn"},
	{2,   "CityID"},
	{2,   "CityID"},
	{2,   "DealCout"},
	{4,   "Wallet"},
	{3,   "DealMoney"},
	{7,   "DealTime"},
	{2,   "DealType"},
	{4,   "RecNumber"},
	{4,   "PsamSN"},
	{2,   "busid"},
	{2,   "lineID"},
	{2,   "FilialeID"},
	{2,   "CardType"},
	{3,   ""},
	{4,   "TAC"},
};


static unsigned char Step=0,StepSum=0;

/*
//记录解析
name:文件名
num:解析的个数
*/
void AnsRec(const char* name,int num,int mode)
{
	U32 i,j,count,rcode,number;
	U08 buf[Rec_Len];

	rcode = APP_Get_RecFileNum(DEF_RecMoryBank_Black01,0,&number);
	if( rcode != 0 )
	{ printf("fail to Get Rec Num!\r\n");}
    else
    { printf("UnSend Rec Num is:%d\r\n",number); }
    
	count = 0;
	for(i = 0;i < num; i++ )
	{
		StepSum = 0;
		Step = 0;
		StepSum += BufStep[Step].Len;
		count++;
		printf("---------------------------------------------(%04d)\r\n",count);
		rcode = APP_Read_RecFile_WriteNot( DEF_RecMoryBank_Black01, count, buf );
	    if( rcode != 0 )
		{ 
			printf("fail to Read Rec NotServer!\r\n");
			return;
		}
		Com_Hook_DebugOutHex(buf,Rec_Len);
		//记录解析
		if( mode == 1)
		{
			for( j = 0; j < Rec_Len; j++)
			{
				printf("%02x ",buf[j]);
				if(j == StepSum-1)
				{
					printf("      ---- %s",BufStep[Step].Note);
					printf("\r\n");
					Step++;
					StepSum+=BufStep[Step].Len;	
				}
			}
			printf("\r\n----------------------------------------------\r\n");
	    }
		
	}
	printf("\r\n=========================over======================\r\n");
}
